<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Linux系列一之常用命令 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="文件解压缩123456#解压*.tar.gztar -zxvf *.tar.gz#解压*.tgztar -zxvf kafka_2.9.2-0.8.2.1.tgz#解压*.zipunzip mysql-5.6.24
创建文件1touch xx.data
文件权限　　命令格式为：chmod [who] operator [permission] filenamewho的含义有：u 文件属主权限、g">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux系列一之常用命令">
<meta property="og:url" content="http://yoursite.com/2015/12/01/linux/1.Linux系列之常用命令/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="文件解压缩123456#解压*.tar.gztar -zxvf *.tar.gz#解压*.tgztar -zxvf kafka_2.9.2-0.8.2.1.tgz#解压*.zipunzip mysql-5.6.24
创建文件1touch xx.data
文件权限　　命令格式为：chmod [who] operator [permission] filenamewho的含义有：u 文件属主权限、g">
<meta property="og:image" content="http://yoursite.com/images/linux-stream.jpg">
<meta property="og:image" content="http://yoursite.com/images/hadoop-ssh.png">
<meta property="og:updated_time" content="2016-01-29T17:47:36.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Linux系列一之常用命令">
<meta name="twitter:description" content="文件解压缩123456#解压*.tar.gztar -zxvf *.tar.gz#解压*.tgztar -zxvf kafka_2.9.2-0.8.2.1.tgz#解压*.zipunzip mysql-5.6.24
创建文件1touch xx.data
文件权限　　命令格式为：chmod [who] operator [permission] filenamewho的含义有：u 文件属主权限、g">
  
    <link rel="alternative" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css" type="text/css">
  

</head>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-linux/1.Linux系列之常用命令" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2015/12/01/linux/1.Linux系列之常用命令/" class="article-date">
  <time datetime="2015-11-30T17:00:00.000Z" itemprop="datePublished">2015-12-01</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/linux/">linux</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      Linux系列一之常用命令
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="u6587_u4EF6_u89E3_u538B_u7F29"><a href="#u6587_u4EF6_u89E3_u538B_u7F29" class="headerlink" title="文件解压缩"></a>文件解压缩</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#解压*.tar.gz</span></span><br><span class="line">tar -zxvf *.tar.gz</span><br><span class="line"><span class="comment">#解压*.tgz</span></span><br><span class="line">tar -zxvf kafka_2.<span class="number">9.2</span>-<span class="number">0.8</span>.<span class="number">2.1</span>.tgz</span><br><span class="line"><span class="comment">#解压*.zip</span></span><br><span class="line">unzip mysql-<span class="number">5.6</span>.<span class="number">24</span></span><br></pre></td></tr></table></figure>
<h2 id="u521B_u5EFA_u6587_u4EF6"><a href="#u521B_u5EFA_u6587_u4EF6" class="headerlink" title="创建文件"></a>创建文件</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">touch xx.data</span><br></pre></td></tr></table></figure>
<h2 id="u6587_u4EF6_u6743_u9650"><a href="#u6587_u4EF6_u6743_u9650" class="headerlink" title="文件权限"></a>文件权限</h2><p>　　命令格式为：chmod [who] operator [permission] filename<br>who的含义有：u 文件属主权限、g 同组用户权限、o其他用户权限、a 所有用户<br>operator的含义有：+ 增加权限、- 取消权限、= 设定权限<br>permission的含义有：r 读权限、w 写权限、x 执行权限<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#收回所有用户的执行权限</span></span><br><span class="line">chmod a-x myfile</span><br><span class="line"><span class="comment">#收回同组用户和其他用户的写权限</span></span><br><span class="line">chmod og-w myfile</span><br><span class="line"><span class="comment">#赋予同组用户写权限</span></span><br><span class="line">chmod g+w myfile</span><br><span class="line"><span class="comment">#赋予文件属主执行权限</span></span><br><span class="line">chmod u+x myfile</span><br><span class="line">本用户执行那个权限，其他用户不可写</span><br><span class="line">chomd u+x o-w myfile </span><br><span class="line"></span><br><span class="line"><span class="comment">#注意：r=4  w=2 x=1</span></span><br><span class="line"><span class="comment">#赋予所有用户读、写和执行权限</span></span><br><span class="line">chmod <span class="number">666</span> myfile</span><br><span class="line"><span class="comment">#赋予文件属主读、写和执行的权限，其他用户读的权限</span></span><br><span class="line">chmod <span class="number">744</span> myfile</span><br><span class="line"><span class="comment">#赋予文件属主读、写和执行的权限</span></span><br><span class="line">chmod <span class="number">700</span> myfile</span><br><span class="line"><span class="comment">#一次设置目录下所有文件</span></span><br><span class="line">chmod <span class="number">755</span> * </span><br><span class="line"><span class="comment">#连同子目录下的文件一起设置</span></span><br><span class="line">chmod -R <span class="number">664</span> </span><br><span class="line"></span><br><span class="line"><span class="comment">#目录的权限 </span></span><br><span class="line"><span class="comment">#读：列出其中的内容。 写：在目录中创建文件。 执行：可以搜索和访问该目录</span></span><br><span class="line"><span class="comment">#注意：目录的权限会覆盖目录中文件的选线</span></span><br></pre></td></tr></table></figure></p>
<h2 id="u7B26_u53F7_u8FDE_u63A5"><a href="#u7B26_u53F7_u8FDE_u63A5" class="headerlink" title="符号连接"></a>符号连接</h2><p>　　符号链接分为软连接和硬链接。软连接类似于windows下的快捷方式。创建命令为 ln<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">touch linkTest</span><br><span class="line"><span class="comment">#创建文件linkTest的快捷方式，保存到/user/linkfile</span></span><br><span class="line">ln <span class="operator">-s</span> linkTest /user/linkfile</span><br></pre></td></tr></table></figure></p>
<h2 id="u6587_u4EF6_u64CD_u4F5C"><a href="#u6587_u4EF6_u64CD_u4F5C" class="headerlink" title="文件操作"></a>文件操作</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#cat完整的显示一个文件，如果需要每次显示一页，</span></span><br><span class="line"><span class="comment">#可以使用more或者把cat命令的输出通过管道传递到另外一个具有分页功能的命令中</span></span><br><span class="line">cat myfile | more</span><br><span class="line"><span class="comment">#将文件myfile1和myfile2文件合并成文件bigfie</span></span><br><span class="line">cat myfile1 myfile2 &gt; bigfile</span><br><span class="line"><span class="comment">#创建一个新文件，并向其中输入一些内容，可以使用cat命令，将标准输出重定向到到新文件</span></span><br><span class="line"><span class="comment">#按CTRL-D结束</span></span><br><span class="line">cat &gt; catfile</span><br></pre></td></tr></table></figure>
<h2 id="crontab"><a href="#crontab" class="headerlink" title="crontab"></a>crontab</h2><p>　　命令形式；crontab [-u user] -e -l -r<br>　　-e编辑crontab文件  -l列出crontab文件中的内容  -r删除crontab文件<br>　　crontab格式：分 时 日 月 星期 要运行的命令。各域中，横杠-表示一个时间范围，逗号表示哪几个时间点，*表示连续的时间段。shell脚本需为绝对路径<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#每晚的21:30运行/apps/bin目录下的cleanup.sh</span></span><br><span class="line"><span class="number">30</span> <span class="number">21</span> * * *  /apps/bin/cleanup.sh</span><br><span class="line"></span><br><span class="line"><span class="comment">#每月1、10、22日的4:45运行/apps/bin目录下的backup.sh</span></span><br><span class="line"><span class="number">45</span> <span class="number">4</span> <span class="number">1</span>,<span class="number">10</span>,<span class="number">22</span> * * /apps/bin/backup.sh</span><br><span class="line"></span><br><span class="line"><span class="comment">#每周六、日的1:10运行一个find命令</span></span><br><span class="line"><span class="number">10</span> <span class="number">1</span> * * <span class="number">6</span>,<span class="number">0</span> find -name <span class="string">"core"</span> -exec rm &#123;&#125; \;</span><br><span class="line"></span><br><span class="line"><span class="comment">#每天18:00至23:00之间每隔30分钟运行/apps/bin目录下的dbcheck.sh</span></span><br><span class="line"><span class="number">0</span>,<span class="number">30</span> <span class="number">18</span>-<span class="number">23</span> * * /apps/bin/dbcheck.sh</span><br><span class="line"></span><br><span class="line"><span class="comment">#在/home/local/test中新建文件testcron，输入</span></span><br><span class="line"><span class="number">0</span>,<span class="number">15</span>,<span class="number">30</span>,<span class="number">45</span> * * * * /bin/<span class="built_in">echo</span> `date` &gt; /dev/console</span><br><span class="line"><span class="comment">#提交任务，后提交的会覆盖之前提交的</span></span><br><span class="line">crontab testcron</span><br><span class="line"></span><br><span class="line"><span class="comment">#在/var/spool/cron中存在文件root，内容与testcron中的一致</span></span><br><span class="line"><span class="comment">#列出crontab文件列表</span></span><br><span class="line">crontab <span class="operator">-l</span></span><br><span class="line"><span class="comment">#可以使用该命令对crontab文件做一备份</span></span><br><span class="line">crontab <span class="operator">-l</span> &gt; <span class="variable">$HOME</span>/mycron <span class="comment">#mycron文件的内容极为crontab -l输出的内容</span></span><br><span class="line"><span class="comment">#编辑crontab文件</span></span><br><span class="line">crontab <span class="operator">-e</span></span><br></pre></td></tr></table></figure></p>
<p>　　at命令：向cron提交守护进程，使其在稍后的时间运行，如果时间太长，比如一个月，则建议使用crontab。<br>　　命令格式：at [-f script] [-m -l -r] [time] [date]<br>　　作业提交后会被拷贝到/var/spool/at目录中。清除一个作业：atrm [job no] 或 at -r [job no]</p>
<ol>
<li>cron：系统调度进程 crontab命令允许用户提交，编辑或删除相应的作业。每一个用户可以有一个crontab文件来保存调度信息</li>
<li>at：使用它在一个的丁的时间运行一些特殊的作业</li>
<li>&amp;：使用它在后台运行一个占用时间不长的进程</li>
<li>nohup：使用他在后台运行一个命令，即使在用户退出时也不受影响</li>
</ol>
<h2 id="umask"><a href="#umask" class="headerlink" title="umask"></a>umask</h2><p>　　设置文件创建时的缺省模式，即<strong>文件创建时不具备的权限</strong>，从下表可以看出，文件在创建时不可能拥有执行权限。使用umask命令设置文件默认的生成掩码，默认的生成掩码告诉系统创建一个文件或目录不应该赋予哪些权限。如果用户将umask命令放在环境文件.bash_profile中，就可以控制所有新建的文件和目录的访问权限。</p>
<table>
<thead>
<tr>
<th style="text-align:center">umask</th>
<th style="text-align:center">文件</th>
<th style="text-align:center">目录</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">0</td>
<td style="text-align:center">6</td>
<td style="text-align:center">7</td>
</tr>
<tr>
<td style="text-align:center">1</td>
<td style="text-align:center">6</td>
<td style="text-align:center">6</td>
</tr>
<tr>
<td style="text-align:center">2</td>
<td style="text-align:center">4</td>
<td style="text-align:center">5</td>
</tr>
<tr>
<td style="text-align:center">3</td>
<td style="text-align:center">4</td>
<td style="text-align:center">4</td>
</tr>
<tr>
<td style="text-align:center">4</td>
<td style="text-align:center">2</td>
<td style="text-align:center">3</td>
</tr>
<tr>
<td style="text-align:center">5</td>
<td style="text-align:center">2</td>
<td style="text-align:center">2</td>
</tr>
<tr>
<td style="text-align:center">6</td>
<td style="text-align:center">0</td>
<td style="text-align:center">1</td>
</tr>
<tr>
<td style="text-align:center">7</td>
<td style="text-align:center">0</td>
<td style="text-align:center">0</td>
</tr>
</tbody>
</table>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#表示设置不允许同组用户和其他用户有写的权限。</span></span><br><span class="line"><span class="built_in">umask</span> <span class="number">022</span></span><br><span class="line"><span class="comment">#显示当前的默认生成掩码。</span></span><br><span class="line"><span class="built_in">umask</span></span><br><span class="line"><span class="comment">#文件创建时的权限为664</span></span><br><span class="line"><span class="built_in">umask</span> <span class="number">002</span></span><br></pre></td></tr></table></figure>
<h2 id="u65E5_u671F_u67E5_u8BE2"><a href="#u65E5_u671F_u67E5_u8BE2" class="headerlink" title="日期查询"></a>日期查询</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#查看系统日期</span></span><br><span class="line">&gt; date</span><br><span class="line">Sat Mar <span class="number">22</span> <span class="number">11</span>:<span class="number">40</span>:<span class="number">49</span> CST <span class="number">2014</span></span><br></pre></td></tr></table></figure>
<h2 id="u6587_u4EF6_u67E5_u627E"><a href="#u6587_u4EF6_u67E5_u627E" class="headerlink" title="文件查找"></a>文件查找</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">&gt; ls <span class="operator">-l</span></span><br><span class="line">total <span class="number">12</span></span><br><span class="line">drwx------. <span class="number">25</span> shihuacai shihuacai <span class="number">4096</span> Feb <span class="number">27</span> <span class="number">22</span>:<span class="number">54</span> shihuacai</span><br><span class="line">-rw-r--r--. <span class="number">1</span> root root <span class="number">4</span> Mar <span class="number">22</span> <span class="number">11</span>:<span class="number">15</span> <span class="built_in">test</span>1</span><br><span class="line">-rw-r--r--. <span class="number">1</span> root root <span class="number">8</span> Mar <span class="number">22</span> <span class="number">11</span>:<span class="number">15</span> <span class="built_in">test</span>2</span><br><span class="line"><span class="comment">#只输出了文件夹，匹配以d开始的</span></span><br><span class="line">&gt; ls <span class="operator">-l</span> | grep ^d  </span><br><span class="line">drwx------. <span class="number">25</span> shihuacai shihuacai <span class="number">4096</span> Feb <span class="number">27</span> <span class="number">22</span>:<span class="number">54</span> shihuacai</span><br><span class="line"></span><br><span class="line"><span class="comment">#在自己的根目录$HOME中查找文件名符合*.txt的文件，并打印</span></span><br><span class="line">find ~ -name <span class="string">"*.txt"</span> -print</span><br><span class="line"></span><br><span class="line"><span class="comment">#使用exec或ok来执行shell命令</span></span><br><span class="line"><span class="comment">#列出当前目录下所有匹配的文件</span></span><br><span class="line">find . -type f -exec ls <span class="operator">-l</span> &#123;&#125; \</span><br><span class="line"></span><br><span class="line"><span class="comment">#在/logs目录中查找更改时间在5日以前的文件并删除它们</span></span><br><span class="line">find logs -type f -mtime +<span class="number">5</span> -ok rm &#123;&#125; \</span><br><span class="line"><span class="comment">#-ok 以安全模式运行，即会提示是否需要删除文件</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#查找系统中的每一个普通文件，然后使用xargs命令来测试他们分别属于哪类文件</span></span><br><span class="line">find / -type f -print | xargs file</span><br><span class="line"></span><br><span class="line"><span class="comment">#在/apps/audit目录下查找所有用户具有读、写和执行权限的文件，并收回相应的写权限</span></span><br><span class="line">find /apps/audit/ -perm -<span class="number">7</span> -print | xargs chmod o-w</span><br><span class="line"></span><br><span class="line"><span class="comment">#在所有的普通文件中搜索device这个词</span></span><br><span class="line">find / -type <span class="operator">-f</span> -print | xargs grep <span class="string">"device"</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#在当前目录下的所有普通文件中搜索DBO这个词，\用来取消find命令中的*在shell中的特殊含义</span></span><br><span class="line">find . -name *\ -type f -print | xargs grep <span class="string">"DBO"</span></span><br></pre></td></tr></table></figure>
<h2 id="chown"><a href="#chown" class="headerlink" title="chown"></a>chown</h2><p>　　修改文件的属主，即修改属于哪个用户。只有文件的属主有权更改其他属主和所属的组<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#将文件aaa的属主变为test</span></span><br><span class="line">chown <span class="built_in">test</span> aaa</span><br><span class="line"><span class="comment">#将文件files的属主和组都改成zh888。</span></span><br><span class="line">chown zh888.zh888 files</span><br><span class="line"><span class="comment">#将files所有目录和子目录下的所有文件或目录的主和组都改成zh888.</span></span><br><span class="line">chown -R zh888.zh888 files</span><br></pre></td></tr></table></figure></p>
<h2 id="u7528_u6237_u64CD_u4F5C"><a href="#u7528_u6237_u64CD_u4F5C" class="headerlink" title="用户操作"></a>用户操作</h2><p>　　1. Linux操作系统是多用户多任务操作系统，包括用户账户和组账户两种，用户账户（普通用户账户，超级用户账户），组账户就是用户账户的集合，centos 组中有两种类型，私有组和标准组。当创建一个新用户时，若没有指定他所属的组，centos就建立一个和该用户相同的私有组，此私有组中只包括用户自己。标准组可以容纳多个用户，如果要使用标准组，那创建一个新的用户时就应该指定他所属于的组。<br>　　2. Linux环境下的账户系统文件主要在/etc/passwd, /etc/shadow, /etc/group和/etc/gshadow四个文件。基本含义就不多说了重点说一下，root的uid是0，从1-499是系统的标准账户，普通用户从uid 500开始。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#添加一个用户zh888</span></span><br><span class="line">useradd zhh888</span><br><span class="line"><span class="comment">#新建一个blog组</span></span><br><span class="line">groupadd blog</span><br><span class="line"><span class="comment">#创建一个新用户zh，同时加入blog附加组中</span></span><br><span class="line">useradd -G blog zh</span><br><span class="line"><span class="comment">#创建一个新用户ftpadmin,指定目录是/var/ftp/pub,不创建自家目录（-M)</span></span><br><span class="line">useradd <span class="operator">-d</span> /var/ftp/pub -M ftpadmin</span><br><span class="line"><span class="comment">#删除ftpadmin用户</span></span><br><span class="line">userdel ftpadmin</span><br><span class="line"><span class="comment">#删除zh888用户并删除/home中的目录。</span></span><br><span class="line">userdel -r zhh888</span><br><span class="line"><span class="comment">#删除blog组</span></span><br><span class="line">groupdel blog</span><br><span class="line">修改已经存在的用户</span><br><span class="line">usermod </span><br><span class="line">修改已经存在的组</span><br><span class="line">groupmod</span><br></pre></td></tr></table></figure></p>
<p>　　当使用groupdel一个组的时候，如果有用户把这个组当作主组，那么删除这个组时就会出现这个报错信息。解决方法就是更换用户的主组，使用usermod -g groupname username。当没有用户把这个组当作主组的时候，使用groupdel groupname时便可以把这个组删除掉。<br>　　注意usermod -g groupname username是把username的主组变成groupname，而usermod -G groupname username只是把用户加到groupname组，并没有改变主组。</p>
<p>　　系统内有关组的信息放在/etc/group文件中，用户的信息放在/etc/passwd文件中。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#查看名为"Plants"的组内的所有用户</span></span><br><span class="line"><span class="comment">#1. 先查询组用户</span></span><br><span class="line">grep <span class="string">'Plants'</span> /etc/group</span><br><span class="line"><span class="comment">#输出：Plants：x：1003，说明gid是1003</span></span><br><span class="line"><span class="comment">#在/etc/passwd中查找组号是1003的用户（/etc/passwd文件中第四列是gid，两列之间用 : 分开）</span></span><br><span class="line">awk -F<span class="string">":"</span> <span class="string">'&#123;print $1"\t\t"$4&#125;'</span> /etc/passwd | grep <span class="string">'1003'</span></span><br><span class="line"><span class="comment"># :表示用:作为分隔符；print 打印；$1和$4分别表示第一列和第四列，即用户名和组号；\t表示制表符；grep '1003'表示将含有1003的行取出。</span></span><br></pre></td></tr></table></figure></p>
<h2 id="awk"><a href="#awk" class="headerlink" title="awk"></a>awk</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#从一个文件中抽取第1个和第5个域，并将其输 出到一个临时文件中</span></span><br><span class="line"><span class="comment">#如果这一操作未成功，我希望能够收到一个相应邮件：</span></span><br><span class="line">awk <span class="string">'&#123;print $1,$5&#125;'</span> test.file &gt; tmp.file || <span class="built_in">echo</span> <span class="string">"failed"</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#将/etc/passwd文件中的第一列内容输出到sort.out文件中</span></span><br><span class="line"><span class="comment">#重定向符号一定要离开sort两个空格（sort排序）</span></span><br><span class="line">cat passwd | awk -F: <span class="string">'&#123;print $1&#125;'</span> | sort <span class="number">1</span>&gt;sort.out</span><br></pre></td></tr></table></figure>
<h2 id="sort"><a href="#sort" class="headerlink" title="sort"></a>sort</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#对文件中的内容进行排序并输出</span></span><br><span class="line">sort &lt; <span class="built_in">test</span>1 <span class="built_in">test</span>2</span><br><span class="line"><span class="comment">#将文件test1和test2 中的内容排序后输出到test1test2sort文件中</span></span><br><span class="line">sort &lt; <span class="built_in">test</span>1 <span class="built_in">test</span>2 &gt; <span class="built_in">test</span>1<span class="built_in">test</span>2sort</span><br></pre></td></tr></table></figure>
<h2 id="vi"><a href="#vi" class="headerlink" title="vi"></a>vi</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 打开文件</span></span><br><span class="line">vi /etc/sysconfig/network</span><br><span class="line"><span class="comment"># 输入i，变成编辑状态</span></span><br><span class="line"><span class="comment"># 编辑完成后，输入esc，</span></span><br><span class="line"><span class="comment"># 保存退出，输入:wq</span></span><br><span class="line"><span class="comment"># 不保存退出，输入:q!</span></span><br></pre></td></tr></table></figure>
<h2 id="24_23__u7EDF_u8BA1_u4F20_u9012_u53C2_u6570_u7684_u4E2A_u6570"><a href="#24_23__u7EDF_u8BA1_u4F20_u9012_u53C2_u6570_u7684_u4E2A_u6570" class="headerlink" title="$# 统计传递参数的个数"></a>$# 统计传递参数的个数</h2><h2 id="u78C1_u76D8_u4FE1_u606F"><a href="#u78C1_u76D8_u4FE1_u606F" class="headerlink" title="磁盘信息"></a>磁盘信息</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#-h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)</span></span><br><span class="line">df -h</span><br><span class="line">df -k | awk <span class="string">'&#123;print $1&#125;'</span>|grep -v <span class="string">"Filesystem"</span></span><br><span class="line"><span class="comment">#不显示/dev/部分</span></span><br><span class="line">df -k | awk <span class="string">'&#123;print $1&#125;'</span>|grep -v <span class="string">"Filesystem"</span> | sed s<span class="string">'/\/dev\///g'</span></span><br></pre></td></tr></table></figure>
<h2 id="tee"><a href="#tee" class="headerlink" title="tee"></a>tee</h2><p>　　将输出的副本输送到标准输出的同时，也拷贝到相应的文件件中<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost home]<span class="comment"># who | tee who.out</span></span><br><span class="line">root tty1 <span class="number">2014</span>-<span class="number">03</span>-<span class="number">22</span> <span class="number">10</span>:<span class="number">29</span> (:<span class="number">0</span>)</span><br><span class="line">root pts/<span class="number">0</span> <span class="number">2014</span>-<span class="number">03</span>-<span class="number">22</span> <span class="number">10</span>:<span class="number">50</span> (:<span class="number">0.0</span>)</span><br><span class="line">root pts/<span class="number">1</span> <span class="number">2014</span>-<span class="number">03</span>-<span class="number">22</span> <span class="number">11</span>:<span class="number">11</span> (:<span class="number">0.0</span>)</span><br><span class="line">root pts/<span class="number">2</span> <span class="number">2014</span>-<span class="number">03</span>-<span class="number">22</span> <span class="number">11</span>:<span class="number">11</span> (:<span class="number">0.0</span>)</span><br><span class="line"></span><br><span class="line">[root@localhost home]<span class="comment"># cat who.out</span></span><br><span class="line">root tty1 <span class="number">2014</span>-<span class="number">03</span>-<span class="number">22</span> <span class="number">10</span>:<span class="number">29</span> (:<span class="number">0</span>)</span><br><span class="line">root pts/<span class="number">0</span> <span class="number">2014</span>-<span class="number">03</span>-<span class="number">22</span> <span class="number">10</span>:<span class="number">50</span> (:<span class="number">0.0</span>)</span><br><span class="line">root pts/<span class="number">1</span> <span class="number">2014</span>-<span class="number">03</span>-<span class="number">22</span> <span class="number">11</span>:<span class="number">11</span> (:<span class="number">0.0</span>)</span><br><span class="line">root pts/<span class="number">2</span> <span class="number">2014</span>-<span class="number">03</span>-<span class="number">22</span> <span class="number">11</span>:<span class="number">11</span> (:<span class="number">0.0</span>)</span><br></pre></td></tr></table></figure></p>
<h2 id="u5185_u5B58_u4FE1_u606F"><a href="#u5185_u5B58_u4FE1_u606F" class="headerlink" title="内存信息"></a>内存信息</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#-b,-k,-m,-g show output in bytes, KB, MB, or GB</span></span><br><span class="line"><span class="comment">#-s update every [delay] seconds</span></span><br><span class="line">free -m <span class="operator">-s</span></span><br></pre></td></tr></table></figure>
<h2 id="u7F51_u7EDC_u4FE1_u606F"><a href="#u7F51_u7EDC_u4FE1_u606F" class="headerlink" title="网络信息"></a>网络信息</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#根据端口或pid查进程</span></span><br><span class="line">netstat -anp | grep <span class="number">9000</span></span><br><span class="line"><span class="comment">#查看指定进程被某些ip的连接数量</span></span><br><span class="line">netstat -anp | grep <span class="number">10.10</span>.*kn | wc <span class="operator">-l</span></span><br><span class="line">netstat -anp | grep kn | wc <span class="operator">-l</span></span><br><span class="line">netstat -ap | grep kn</span><br></pre></td></tr></table></figure>
<h2 id="nohup"><a href="#nohup" class="headerlink" title="nohup"></a>nohup</h2><p>　　如果使用&amp;提交了一个后台进程，在退出时（如退出账户）该进程将会被终止。可以使用nohup命令，在退出后继续运行。nohup就是不挂起的意思 no hang up。使用nohup提交作业，如果一次提交几个作业，则将其写到一个shell脚本中，并用nohup命令来执行它<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nohup <span class="built_in">command</span> &gt; myout.file <span class="number">2</span>&gt;&amp;<span class="number">1</span></span><br></pre></td></tr></table></figure></p>
<h2 id="u8FDB_u7A0B_u4FE1_u606F"><a href="#u8FDB_u7A0B_u4FE1_u606F" class="headerlink" title="进程信息"></a>进程信息</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#查看含有java关键字的进程信息</span></span><br><span class="line">ps -ef | grep java</span><br></pre></td></tr></table></figure>
<h2 id="u64CD_u4F5C_u7CFB_u7EDF_u4FE1_u606F"><a href="#u64CD_u4F5C_u7CFB_u7EDF_u4FE1_u606F" class="headerlink" title="操作系统信息"></a>操作系统信息</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#centos系统版本，输出CentOS release 6.3 (Final)</span></span><br><span class="line">cat /etc/issue</span><br><span class="line"><span class="comment">#打印kernel等版本信息：Linux version 2.6.32-279.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Fri Jun 22 12:19:21 UTC 2012</span></span><br><span class="line">cat /proc/version</span><br><span class="line"></span><br><span class="line"><span class="comment">#centos系统位数，如果有lib64或这个目录，那操作系统就是64位的。</span></span><br><span class="line">ls /</span><br><span class="line"><span class="comment">#若为X86示意为64位系统，i386则为32位系统，uname命令可以显示内核的详细信息</span></span><br><span class="line"><span class="comment">#centos64位系统输出：Linux push1 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux</span></span><br><span class="line">uname <span class="operator">-a</span></span><br></pre></td></tr></table></figure>
<h2 id="u8FDC_u7A0B_u62F7_u8D1D"><a href="#u8FDC_u7A0B_u62F7_u8D1D" class="headerlink" title="远程拷贝"></a>远程拷贝</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#将本地/home/Administrator/file01文件拷贝到远程机器的/home/file01</span></span><br><span class="line">scp /home/Administrator/file01 root@<span class="number">192.168</span>.<span class="number">151.129</span>:/home/file01</span><br><span class="line"></span><br><span class="line"><span class="comment">#将本地/home/文件夹下的所有文件（**不包括子文件夹**）拷贝到远程机器的/root/Test/文件夹</span></span><br><span class="line">scp /home/* root@<span class="number">192.168</span>.<span class="number">151.129</span>:/root/Test/</span><br><span class="line"></span><br><span class="line"><span class="comment">#将本地/root/zhhx/files/文件夹下的所有文件（包括子文件夹）拷贝到远程机器的root@192.168.85.66:/home/test/文件夹下</span></span><br><span class="line">scp -r /root/zhhx/files root@<span class="number">192.168</span>.<span class="number">85.66</span>:/home/<span class="built_in">test</span>/</span><br><span class="line"></span><br><span class="line"><span class="comment">#将本地/usr/local/kafka_2.9.2-0.8.2.1/文件夹下的所有文件（包括子文件夹）拷贝到远程机器的/usr/local/kafka_2.9.2-0.8.2.1/文件夹</span></span><br><span class="line">scp -r /usr/<span class="built_in">local</span>/kafka_2.<span class="number">9.2</span>-<span class="number">0.8</span>.<span class="number">2.1</span>/* root@<span class="number">192.168</span>.<span class="number">241.130</span>:/usr/<span class="built_in">local</span>/kafka_2.<span class="number">9.2</span>-<span class="number">0.8</span>.<span class="number">2.1</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#将远程文件夹copy到当前系统的/home文件夹下(文件名不变)</span></span><br><span class="line">scp root@<span class="number">192.168</span>.<span class="number">151.129</span>:/root/index.html /home/</span><br><span class="line"></span><br><span class="line"><span class="comment">#将远程root文件夹下所有文件（不包括子文件夹）到当前系统的/home/test文件夹下</span></span><br><span class="line">scp root@<span class="number">192.168</span>.<span class="number">151.129</span>:/root/* /home/<span class="built_in">test</span>/</span><br><span class="line"></span><br><span class="line"><span class="comment">#将远程文件夹root（子文件，子文件夹）全部拷贝到本地/home/test/目录下（在test下生成文件夹root）</span></span><br><span class="line">scp -r root@<span class="number">192.168</span>.<span class="number">151.129</span>:/root /home/<span class="built_in">test</span>/</span><br><span class="line"></span><br><span class="line"><span class="comment">#将远程文件夹root（子文件，子文件夹）全部拷贝到本地/home/test目录下(root文件夹重命名为test)</span></span><br><span class="line">scp -r root@<span class="number">192.168</span>.<span class="number">151.129</span>:/root /home/<span class="built_in">test</span></span><br></pre></td></tr></table></figure>
<h2 id="u6253_u5370_u6587_u4EF6_u8FFD_u52A0_u7684_u65B0_u5185_u5BB9"><a href="#u6253_u5370_u6587_u4EF6_u8FFD_u52A0_u7684_u65B0_u5185_u5BB9" class="headerlink" title="打印文件追加的新内容"></a>打印文件追加的新内容</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#output appended data as the file grows; -f, --follow, and --follow=descriptor are equivalent</span></span><br><span class="line">tail <span class="operator">-f</span> <span class="number">100</span></span><br></pre></td></tr></table></figure>
<h2 id="u7CFB_u7EDF_u542F_u52A8_u7EA7_u522B"><a href="#u7CFB_u7EDF_u542F_u52A8_u7EA7_u522B" class="headerlink" title="系统启动级别"></a>系统启动级别</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#centos7</span></span><br><span class="line">cat /etc/inittab </span><br><span class="line"><span class="comment"># inittab is no longer used when using systemd. </span></span><br><span class="line"><span class="comment"># </span></span><br><span class="line"><span class="comment"># ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM. </span></span><br><span class="line"><span class="comment"># </span></span><br><span class="line"><span class="comment"># Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target </span></span><br><span class="line"><span class="comment"># </span></span><br><span class="line"><span class="comment"># systemd uses 'targets' instead of runlevels. By default, there are two main targets: </span></span><br><span class="line"><span class="comment"># </span></span><br><span class="line"><span class="comment"># multi-user.target: analogous to runlevel 3 </span></span><br><span class="line"><span class="comment"># graphical.target: analogous to runlevel 5 </span></span><br><span class="line"><span class="comment"># </span></span><br><span class="line"><span class="comment"># To set a default target, run: </span></span><br><span class="line"><span class="comment"># </span></span><br><span class="line"><span class="comment"># ln -sf /lib/systemd/system/&lt;target name&gt;.target /etc/systemd/system/default.target </span></span><br><span class="line"><span class="comment"># </span></span><br><span class="line"><span class="comment"># 以命令行的形式启动</span></span><br><span class="line">ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target</span><br></pre></td></tr></table></figure>
<h2 id="u9632_u706B_u5899"><a href="#u9632_u706B_u5899" class="headerlink" title="防火墙"></a>防火墙</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#查看防火墙状态</span></span><br><span class="line">service iptables status</span><br><span class="line"></span><br><span class="line"><span class="comment">#查看防火墙随机启动时的状态</span></span><br><span class="line">&gt; chkconfig --list | grep iptables</span><br><span class="line">iptables       <span class="number">0</span>:off	<span class="number">1</span>:off	<span class="number">2</span>:on	<span class="number">3</span>:on	<span class="number">4</span>:on	<span class="number">5</span>:on	<span class="number">6</span>:off</span><br><span class="line"></span><br><span class="line"><span class="comment">#永久性关闭防火墙：</span></span><br><span class="line">chkconfig --level <span class="number">35</span> iptables off</span><br><span class="line">chkconfig iptables off</span><br><span class="line"><span class="comment">#两者的区别是</span></span><br><span class="line">--level <span class="number">35</span>之后的状态是：iptables      <span class="number">0</span>:off  <span class="number">1</span>:off	<span class="number">2</span>:on	<span class="number">3</span>:off	<span class="number">4</span>:on	<span class="number">5</span>:off	<span class="number">6</span>:off</span><br><span class="line">无--level参数的状态是：iptables       <span class="number">0</span>:off	 <span class="number">1</span>:off	<span class="number">2</span>:off	<span class="number">3</span>:off	<span class="number">4</span>:off	<span class="number">5</span>:off	<span class="number">6</span>:off</span><br><span class="line">	   </span><br><span class="line">	   </span><br><span class="line"></span><br><span class="line"><span class="comment">#临时的修改防火墙状态</span></span><br><span class="line">service iptables stop               <span class="comment">## 本次关闭防火墙</span></span><br><span class="line">service iptables restart            <span class="comment">## 重启防火墙</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#Centos7中防火墙改iptables改成了firewall</span></span><br><span class="line"><span class="comment">#启动firewall</span></span><br><span class="line">systemctl start firewalld.service</span><br><span class="line"><span class="comment">#停止firewall</span></span><br><span class="line">systemctl stop firewalld.service</span><br><span class="line"><span class="comment">#禁止firewall开机启动</span></span><br><span class="line">systemctl <span class="built_in">disable</span> firewalld.service</span><br><span class="line"><span class="comment">#查看防火墙状态</span></span><br><span class="line">systemctl status firewalld.service</span><br><span class="line"></span><br><span class="line"><span class="comment">#设置防火墙开放端口</span></span><br><span class="line"><span class="comment">#修改文件/etc/sysconfig/iptables，开放22端口</span></span><br><span class="line">-A INPUT -m state --state NEW -m tcp -p tcp --dport <span class="number">22</span> -j ACCEPT</span><br><span class="line"><span class="comment">#全部修改完之后重启iptables:service iptables restart</span></span><br><span class="line"><span class="comment">#验证规则是否都已经生效：iptables -L</span></span><br></pre></td></tr></table></figure>
<h2 id="u7F51_u7EDC_u6D41_u91CF"><a href="#u7F51_u7EDC_u6D41_u91CF" class="headerlink" title="网络流量"></a>网络流量</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#安装iptraf</span></span><br><span class="line">yum -y install gcc</span><br><span class="line">yum -y install glibc</span><br><span class="line">yum -y install ncurses</span><br><span class="line">安装完毕之后 我们现在开始安装iptraf</span><br><span class="line">yum -y install iptraf</span><br><span class="line"><span class="comment">#完毕后查找下 locate iptraf</span></span><br><span class="line"><span class="comment">#查看网络流量</span></span><br><span class="line">iptraf <span class="operator">-d</span> eth0</span><br></pre></td></tr></table></figure>
<h2 id="26amp_3B"><a href="#26amp_3B" class="headerlink" title="&amp;"></a>&amp;</h2><p>　　放在启动参数后面表示设置此进程为后台进程，后台京城可以称之为job。切换到后台时会输出相关job信息，输出信息如：[1] 11319，[1]表示job ID是1,11319表示进程ID是11319。切换到后台的进程，仍然可以用ps命令查看。<br>　　进程前后台间切换可以通过bg <jobid>（background）和fg<jobid>（foreground）命令。</jobid></jobid></p>
<h2 id="u5B88_u62A4_u8FDB_u7A0B"><a href="#u5B88_u62A4_u8FDB_u7A0B" class="headerlink" title="守护进程"></a>守护进程</h2><p>　　如果一个进程永远都是以后台方式启动，并且不受到Shell退出影响而退出，一个正统的做法是将其创建为守护进程。守护进程是系统长期运行的后台进程，类似Windows服务。守护进程信息通过 ps –a 无法查看到，需要用到 –x 参数，当使用这条命令的时候，往往还附上 -j 参数以查看作业控制信息，其中TPGID一栏为-1就是守护进程。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&gt; ps xj</span><br><span class="line">　　PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND</span><br><span class="line">　　<span class="number">953</span> <span class="number">1190</span> <span class="number">1190</span> <span class="number">1190</span> ? -<span class="number">1</span> Ss <span class="number">1000</span> <span class="number">0</span>:<span class="number">00</span> /bin/sh /usr/bin/startkde</span><br><span class="line">　　<span class="number">1</span> <span class="number">1490</span> <span class="number">1482</span> <span class="number">1482</span> ? -<span class="number">1</span> Sl <span class="number">1000</span> <span class="number">0</span>:<span class="number">00</span> /usr/bin/VBoxClient –seamless</span><br><span class="line">　　<span class="number">1</span> <span class="number">1491</span> <span class="number">1477</span> <span class="number">1477</span> ? -<span class="number">1</span> Sl <span class="number">1000</span> <span class="number">0</span>:<span class="number">00</span> /usr/bin/VBoxClient –display</span><br></pre></td></tr></table></figure></p>
<h2 id="26amp_3B_26amp_3B__7C_7C"><a href="#26amp_3B_26amp_3B__7C_7C" class="headerlink" title="&amp;&amp; ||"></a>&amp;&amp; ||</h2><p>　　shell 在执行某个命令的时候，会返回一个返回值，该<strong>返回值保存在 shell 变量 $? 中</strong>。当 $? == 0 时，表示执行成功；当 $? == 1 时（我认为是非0的数，返回值在0-255间），表示执行失败。<br>　　有时候，下一条命令依赖前一条命令是否执行成功。如：在成功地执行一条命令之后再执行另一条命令，或者在一条命令执行失败后再执行另一条命令等。shell 提供了 &amp;&amp; 和 || 来实现命令执行控制的功能，shell 将根据 &amp;&amp; 或 || 前面命令的返回值来控制其后面命令的执行，语法格式如下：<br>　　command1 &amp;&amp; command2 [&amp;&amp; command3 …]<br>　　1. 命令之间使用 &amp;&amp; 连接，实现逻辑与的功能。<br>　　2. 只有在 &amp;&amp; 左边的命令返回真（命令返回值 $? == 0），&amp;&amp; 右边的命令才会被执行。#cmd1返回0（成功执行）后，cmd2才能够被执行<br>　　3. 只要有一个命令返回假（返回值 $? == 1），后面的命令就不会被执行，实现短路的功能</p>
<p>　　command1 || command2 [|| command3 …]<br>　　1. 命令之间使用 || 连接，实现 逻辑或的功能。<br>　　2. 只有在 || 左边的命令返回假（命令返回值 $? == 1），|| 右边的命令才会被执行。这和 c 语言中的逻辑或语法功能相同，即实现短路逻辑或操作。#cmd1返回1（成功失败）后，cmd2才能够被执行<br>　　3. 只要有一个命令返回真（命令返回值 $? == 0），后面的命令就不会被执行。即一直到返回真的地方停止执行。</p>
<h2 id="2__26gt_3B__26amp_3B1"><a href="#2__26gt_3B__26amp_3B1" class="headerlink" title="2 &gt; &amp;1"></a>2 &gt; &amp;1</h2><p>　　首先在linux中，0表示键盘输入，1表示屏幕输出，2表示错误输出，而 &gt; 表示重定向。对于 &amp;1 更准确的说应该是文件描述符 1，而1一般代表的就是STDOUT_FILENO，<br>　　/mnt/Nand3/H2000G  &gt; /dev/null  2&gt;&amp;1：把标准错误重定向到标准输出，然后扔到/dev/null下面去。通俗的说，就是把所有标准输出和标准出错都扔到垃圾桶里面。<br>　　command &gt; out.file 2 &gt; &amp;1 &amp;：将command的输出重定向到out.file文件，即输出内容不打印到屏幕上，而是输出到out.file文件中。 2&gt;&amp;1 是将标准出错重定向到标准输出，这里的标准输出已经重定向到了out.file文件，即将标准出错也输出到out.file文件中。最后一个&amp; ， 是让该命令在后台执行。<br>　　2 &gt; 1：2与 &gt; 结合代表错误重定向，而1则代表错误重定向到一个文件1，而不代表标准输出；换成2&gt;&amp;1，&amp;与1结合就代表标准输出了，就变成错误重定向到标准输出。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#输出一个空的文件1</span></span><br><span class="line">ls <span class="number">2</span>&gt;<span class="number">1</span></span><br><span class="line"><span class="comment">#没有xxx这个文件的错误输出到了1中</span></span><br><span class="line">ls xxx <span class="number">2</span>&gt;<span class="number">1</span></span><br><span class="line"><span class="comment">#不会生成1这个文件了，不过错误跑到标准输出</span></span><br><span class="line">ls xxx <span class="number">2</span>&gt;&amp;<span class="number">1</span></span><br><span class="line"><span class="comment">#可换成 ls xxx 1&gt;out.txt 2&gt;&amp;1；重定向符号&gt;默认是1,错误和输出都传到out.txt了</span></span><br><span class="line">ls xxx &gt; out.txt <span class="number">2</span>&gt;&amp;<span class="number">1</span></span><br></pre></td></tr></table></figure></p>
<p>　　为何2&gt;&amp;1要写在后面？command &gt; file 2&gt;&amp;1。首先是command &gt; file将标准输出重定向到file中， 2&gt;&amp;1是标准错误拷贝了标准输出的行为，也就是同样被重定向到file中，最终结果就是标准输出和错误都被重定向到file中。<br>　　command 2&gt;&amp;1 &gt;file：2&gt;&amp;1 标准错误拷贝了标准输出的行为，但此时标准输出还是在终端。&gt;file 后输出才被重定向到file，但标准错误仍然保持在终端。</p>
<h2 id="u6807_u51C6_u8F93_u5165_u8F93_u51FA"><a href="#u6807_u51C6_u8F93_u5165_u8F93_u51FA" class="headerlink" title="标准输入输出"></a>标准输入输出</h2><p>　　0：标准输入 1：标准输出 2：标准错误<br><img src="/images/linux-stream.jpg" alt="linux-stream.jpg"></p>
<h2 id="u4FEE_u6539_u4E3B_u673A_u540D"><a href="#u4FEE_u6539_u4E3B_u673A_u540D" class="headerlink" title="修改主机名"></a>修改主机名</h2><p>　　CentOS6中修改主机方法，假设三台虚拟机的名字分别为：master，slave1，slave2<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 第一处 /etc/sysconfig/network</span></span><br><span class="line">NETWORKING=yes　　　　　　<span class="comment">#使用网络</span></span><br><span class="line">HOSTNAME=centos　　　　　 <span class="comment">#设置主机名称，默认为HOSTNAME=localhost.localdomain</span></span><br><span class="line"><span class="comment"># 终端中输入：hostname centos        #立即生效</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 第二处 /etc/hosts </span></span><br><span class="line">&gt; cat /etc/hosts </span><br><span class="line"><span class="number">127.0</span>.<span class="number">0.1</span> localhost.localdomain localhost</span><br><span class="line"><span class="comment"># 127.0.0.1 是本地环路地址，</span></span><br><span class="line"><span class="comment"># localhost.localdomain 是主机名(hostname)，也就是待修改的</span></span><br><span class="line"><span class="comment"># localhost 是主机名的别名（alias），它会出现在Konsole的提示符下。将第二项修改为你的主机名，第三项可选。</span></span><br><span class="line"><span class="comment"># 修改完这两处后重启，用 uname -n 命令来查看是否修改成功。</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 同时在master机器的 /etc/hosts文件中增加三行（master要根据主机名找其他两台机器，hadoop的etc配置文件用的主机名）</span></span><br><span class="line"><span class="number">192.168</span>.<span class="number">254.133</span> master</span><br><span class="line"><span class="number">192.168</span>.<span class="number">254.134</span> slave1</span><br><span class="line"><span class="number">192.168</span>.<span class="number">254.135</span> slave2</span><br><span class="line"></span><br><span class="line"><span class="comment"># slave1和slave2的/etc/hosts增加一行</span></span><br><span class="line"><span class="comment"># slave需要寻找master，否则在启动yarn后，slave机器上会没有NodeManager进程</span></span><br><span class="line"><span class="number">192.168</span>.<span class="number">254.133</span> master</span><br><span class="line"></span><br><span class="line"><span class="comment"># 重启网络服务</span></span><br><span class="line">service network restart</span><br></pre></td></tr></table></figure></p>
<p>　　在CentOS7中，有三种定义的主机名:静态的（static），瞬态的（transient），和灵活的（pretty）。“静态”主机名也称为内核主机名，是系统在启动时从/etc/hostname自动初始化的主机名。“瞬态”主机名是在系统运行时临时分配的主机名，例如，通过DHCP或mDNS服务器分配。静态主机名和瞬态主机名都遵从作为互联网域名同样的字符限制规则。而另一方面，“灵活”主机名则允许使用自由形式（包括特殊/空白字符）的主机名，以展示给终端用户（如Linuxidc）。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&gt; hostnamectl</span><br><span class="line">&gt; hostnamectl status</span><br><span class="line"><span class="comment">#只查看静态主机名</span></span><br><span class="line">&gt; hostnamectl --static</span><br><span class="line"><span class="comment">#只查看瞬态主机名</span></span><br><span class="line">&gt; hostnamectl --transient</span><br><span class="line"><span class="comment">#只查看灵活主机名</span></span><br><span class="line">&gt; hostnamectl --pretty</span><br><span class="line"></span><br><span class="line"><span class="comment">#同时修改所有三个主机名：静态、瞬态和灵活主机名：</span></span><br><span class="line">&gt; hostnamectl <span class="built_in">set</span>-hostname Linuxidc</span><br><span class="line"><span class="comment">#只修改特定的主机名（静态，瞬态或灵活），使用--static，--transient或--pretty选项。</span></span><br><span class="line">&gt; hostnamectl --static <span class="built_in">set</span>-hostname Linuxidc</span><br><span class="line"><span class="comment">#不必重启机器以激活永久主机名修改。上面的命令会立即修改内核主机名。注销并重新登入后在命令行提示来观察新的静态主机名。</span></span><br></pre></td></tr></table></figure></p>
<h2 id="SSH_u514D_u5BC6_u7801_u767B_u5F55"><a href="#SSH_u514D_u5BC6_u7801_u767B_u5F55" class="headerlink" title="SSH免密码登录"></a>SSH免密码登录</h2><p>　　Hadoop的namenode使用SSH协议启动namenode和datanode进程，同时datanode向namenode传递心跳信息可能也是使用SSH协议<br>　　以namenode到datanode为例子：Namenode作为客户端，要实现无密码公钥认证，连接到服务端datanode上时，需要在namenode上生成一个密钥对，包括一个公钥和一个私钥，而后将公钥复制到datanode上。当namenode通过ssh连接datanode时，datanode就会生成一个随机数并用namenode的公钥对随机数进行加密，并发送给namenode。namenode收到加密数之后再用私钥进行解密，并将解密数回传给datanode，datanode确认解密数无误之后就允许namenode进行连接了。这就是一个公钥认证过程，其间不需要用户手工输入密码。重要过程是将客户端namenode公钥复制到datanode上。<br>　　默认CentOS已经安装了OpenSSH，即使你是最小化安装也是如此。SSH的配置步骤为：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># root用户登录</span></span><br><span class="line">gedit /etc/selinux/config </span><br><span class="line"><span class="comment"># 设置SELINUX=disabled(ssh配置如果没问题，可以省略该步骤)</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 假设从A机器连接到B机器，A机器操作（hadoop用户）</span></span><br><span class="line">&gt; ssh-keygen</span><br><span class="line"><span class="comment"># 在/home/hadoop/.ssh目录下自动生成了文件id_rsa和id_rsa.pub</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 以下两步貌似不需要执行</span></span><br><span class="line">&gt; cat id_rsa.pub &gt;&gt; authorized_keys</span><br><span class="line">&gt; chmod <span class="number">600</span> authorized_keys</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将A机器公钥拷贝到B机器的/home/hadoop/.ssh目录下</span></span><br><span class="line">&gt; scp id_rsa.pub hadoop@<span class="number">192.168</span>.<span class="number">254.134</span>:.ssh/id_rsa.pub</span><br><span class="line">   </span><br><span class="line"><span class="comment"># 进入B机器的/home/hadoop/.ssh目录</span></span><br><span class="line">&gt; cat id_rsa.pub &gt;&gt; authorized_keys</span><br><span class="line"><span class="comment"># 或者执行</span></span><br><span class="line">&gt; mv id_rsa.pub authorized_keys</span><br><span class="line"></span><br><span class="line"><span class="comment"># B机器上需要的是authorized_keys，A机器上拷贝过来的id_rsa.pub可以删除。</span></span><br><span class="line"><span class="comment"># 如果是多个机器都要免密码登陆B机器，则还是使用cat id_rsa.pub &gt;&gt; authorized_keys，</span></span><br><span class="line"><span class="comment"># 将id_rsa.pub文件的内容追加到B机器的authorized_keys文件</span></span><br><span class="line"></span><br><span class="line">&gt; 执行chmod <span class="number">600</span> authorized_keys（该步骤不可省略）</span><br><span class="line">    </span><br><span class="line"><span class="comment"># 回到A机器，连接B机器</span></span><br><span class="line">&gt; ssh <span class="number">192.168</span>.<span class="number">254.134</span></span><br><span class="line"><span class="comment"># 第一次连接时会提示是否连接至B机器，直接输入yes，但是无需输入密码，</span></span><br><span class="line"><span class="comment"># 连接成功后会在A机器的/home/hadoop/.ssh目录下生成文件known_hosts）</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 执行mkdir test，此时在B机器上的/home/hadoop目录中可以看到生成了目录test。</span></span><br><span class="line"><span class="comment"># 如果删除A机器中的known_hosts，再连接B时，会成为第一次连接，回到步骤5</span></span><br></pre></td></tr></table></figure></p>
<p>　　在hadoop的配置中，均是根据hostname来进行ssh连接的，故需要在/etc/ssh中增加对应的ip hostname行信息后，再执行ssh slave1，初始连接。否则在启动./sbin/start-dfs.sh时，程序停顿如下图所示处：<img src="/images/hadoop-ssh.png" alt="hadoop-ssh.png"><br>　　在每台服务器上执行ssh-copy-id命令，自动将公钥复制到其它服务器上的authorized_keys的文件中，这里的ssh端口是18330，所以执行ssh-copy-id命令要带上端口号：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-copy-id -i ~/.ssh/id_rsa.pub <span class="string">"-p 18330 root@192.168.1.253"</span></span><br></pre></td></tr></table></figure></p>
<h2 id="u53C2_u8003_u8D44_u6599"><a href="#u53C2_u8003_u8D44_u6599" class="headerlink" title="参考资料"></a>参考资料</h2><p><a href="http://www.cnblogs.com/TianFang/archive/2013/01/23/2872645.html" target="_blank" rel="external">http://www.cnblogs.com/TianFang/archive/2013/01/23/2872645.html</a> </p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2015/12/01/linux/1.Linux系列之常用命令/" data-id="cijzzpvcv00bt1cfs6em03op4" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/linux/">linux</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2015/12/01/rpc/2.RPC系列之Hessian源码分析/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          RPC系列二之Hessian源码分析
        
      </div>
    </a>
  
  
    <a href="/2015/12/01/groovy/1.groovy入门/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">Linux系列一之常用命令</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/cache/">cache</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a><span class="category-list-count">13</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/">docker</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/gis/">gis</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/git/">git</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/go/">go</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/gradle/">gradle</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/groovy/">groovy</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/hadoop/">hadoop</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/java/">java</a><span class="category-list-count">18</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/log/">log</a><span class="category-list-count">11</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mongodb/">mongodb</a><span class="category-list-count">14</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mq/">mq</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mybatis/">mybatis</a><span class="category-list-count">9</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/netty/">netty</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nginx/">nginx</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nio/">nio</a><span class="category-list-count">19</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nodejs/">nodejs</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/redis/">redis</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/rpc/">rpc</a><span class="category-list-count">14</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/spring/">spring</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/tomcat/">tomcat</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/zookeeper/">zookeeper</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/杂项/">杂项</a><span class="category-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/aop/">aop</a><span class="tag-list-count">8</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/aspectj/">aspectj</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/classloader/">classloader</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/common-loggings/">common-loggings</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/commonjs/">commonjs</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/">docker</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dubbo/">dubbo</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/fastdfs/">fastdfs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gclib/">gclib</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/geohash/">geohash</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gis/">gis</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/go/">go</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gradle/">gradle</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/groovy/">groovy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hadoop/">hadoop</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hessisan/">hessisan</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a><span class="tag-list-count">48</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javassist/">javassist</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kafka/">kafka</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log/">log</a><span class="tag-list-count">11</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log4j/">log4j</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/logback/">logback</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/map/">map</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memecached/">memecached</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mina/">mina</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mongodb/">mongodb</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mq/">mq</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mqtt/">mqtt</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mybatis/">mybatis</a><span class="tag-list-count">9</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netty/">netty</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/">nginx</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nio/">nio</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nodejs/">nodejs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/postgresql/">postgresql</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/proxy/">proxy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/push/">push</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rabbitmq/">rabbitmq</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/">redis</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rpc/">rpc</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sitemesh/">sitemesh</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sld/">sld</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/slf4j/">slf4j</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/socket/">socket</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spatialite-for-android/">spatialite for android</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spi/">spi</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spring/">spring</a><span class="tag-list-count">13</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tomcat/">tomcat</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/transaction/">transaction</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/web/">web</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xSocket/">xSocket</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zbus/">zbus</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zookeeper/">zookeeper</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/数据结构/">数据结构</a><span class="tag-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/aop/" style="font-size: 15.38px;">aop</a> <a href="/tags/aspectj/" style="font-size: 11.54px;">aspectj</a> <a href="/tags/cache/" style="font-size: 11.54px;">cache</a> <a href="/tags/classloader/" style="font-size: 10px;">classloader</a> <a href="/tags/common-loggings/" style="font-size: 10px;">common-loggings</a> <a href="/tags/commonjs/" style="font-size: 12.31px;">commonjs</a> <a href="/tags/database/" style="font-size: 16.92px;">database</a> <a href="/tags/docker/" style="font-size: 13.85px;">docker</a> <a href="/tags/dubbo/" style="font-size: 10px;">dubbo</a> <a href="/tags/fastdfs/" style="font-size: 10px;">fastdfs</a> <a href="/tags/gclib/" style="font-size: 10.77px;">gclib</a> <a href="/tags/geohash/" style="font-size: 10px;">geohash</a> <a href="/tags/gis/" style="font-size: 10px;">gis</a> <a href="/tags/git/" style="font-size: 10.77px;">git</a> <a href="/tags/go/" style="font-size: 10px;">go</a> <a href="/tags/gradle/" style="font-size: 10px;">gradle</a> <a href="/tags/groovy/" style="font-size: 10px;">groovy</a> <a href="/tags/hadoop/" style="font-size: 10px;">hadoop</a> <a href="/tags/hessisan/" style="font-size: 11.54px;">hessisan</a> <a href="/tags/java/" style="font-size: 20px;">java</a> <a href="/tags/javassist/" style="font-size: 10px;">javassist</a> <a href="/tags/kafka/" style="font-size: 11.54px;">kafka</a> <a href="/tags/linux/" style="font-size: 12.31px;">linux</a> <a href="/tags/log/" style="font-size: 17.69px;">log</a> <a href="/tags/log4j/" style="font-size: 12.31px;">log4j</a> <a href="/tags/logback/" style="font-size: 13.08px;">logback</a> <a href="/tags/map/" style="font-size: 10px;">map</a> <a href="/tags/memecached/" style="font-size: 10.77px;">memecached</a> <a href="/tags/mina/" style="font-size: 13.08px;">mina</a> <a href="/tags/mongodb/" style="font-size: 19.23px;">mongodb</a> <a href="/tags/mq/" style="font-size: 13.85px;">mq</a> <a href="/tags/mqtt/" style="font-size: 10.77px;">mqtt</a> <a href="/tags/mybatis/" style="font-size: 16.15px;">mybatis</a> <a href="/tags/netty/" style="font-size: 10px;">netty</a> <a href="/tags/nginx/" style="font-size: 11.54px;">nginx</a> <a href="/tags/nio/" style="font-size: 13.08px;">nio</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/postgresql/" style="font-size: 10.77px;">postgresql</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/proxy/" style="font-size: 10px;">proxy</a> <a href="/tags/push/" style="font-size: 10px;">push</a> <a href="/tags/rabbitmq/" style="font-size: 11.54px;">rabbitmq</a> <a href="/tags/redis/" style="font-size: 13.85px;">redis</a> <a href="/tags/rpc/" style="font-size: 19.23px;">rpc</a> <a href="/tags/sitemesh/" style="font-size: 10px;">sitemesh</a> <a href="/tags/sld/" style="font-size: 10px;">sld</a> <a href="/tags/slf4j/" style="font-size: 10px;">slf4j</a> <a href="/tags/socket/" style="font-size: 14.62px;">socket</a> <a href="/tags/spatialite-for-android/" style="font-size: 10px;">spatialite for android</a> <a href="/tags/spi/" style="font-size: 10px;">spi</a> <a href="/tags/spring/" style="font-size: 18.46px;">spring</a> <a href="/tags/tomcat/" style="font-size: 10.77px;">tomcat</a> <a href="/tags/transaction/" style="font-size: 10px;">transaction</a> <a href="/tags/web/" style="font-size: 10px;">web</a> <a href="/tags/xSocket/" style="font-size: 14.62px;">xSocket</a> <a href="/tags/zbus/" style="font-size: 10px;">zbus</a> <a href="/tags/zookeeper/" style="font-size: 10.77px;">zookeeper</a> <a href="/tags/数据结构/" style="font-size: 10.77px;">数据结构</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a><span class="archive-list-count">67</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">December 2015</a><span class="archive-list-count">81</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a><span class="archive-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/01/30/资料/">(no title)</a>
          </li>
        
          <li>
            <a href="/2016/01/30/java/13.Classloader系列一/">ClassLoader系列一</a>
          </li>
        
          <li>
            <a href="/2016/01/29/hadoop/1.hadoop系列之源码编译/">hadoop系列一之源码编译</a>
          </li>
        
          <li>
            <a href="/2016/01/29/go/1.GO系列之入门/">Go系列一之入门</a>
          </li>
        
          <li>
            <a href="/2016/01/28/tomcat/2.tomcat性能优化/">tomcat性能优化</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="http://libs.baidu.com/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">
  <script src="/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script>


<script src="/js/script.js" type="text/javascript"></script>

  </div>
</body>
</html>